#include "UiBTTopBar.h"
#ifdef MERGER_APP_TO_SHELL
	extern HINSTANCE g_SDHResModuleHandle;
#endif
UiBTTopBar::UiBTTopBar()
{
}

UiBTTopBar::~UiBTTopBar()
{
}

BOOL UiBTTopBar::InitUiWin(void)
{
	BOOL bRtn = FALSE;
//	SetWindowLong(m_hWnd, GWL_USERDATA, (LONG) this);
	LoadiInterItem();
	InitImages();
	return bRtn;
}

void UiBTTopBar::PaintWin(HDC hdc, RECT* prcWin, RECT* prcUpdate)
{
	m_TopBarBG->Draw(hdc, prcWin, false, false);
}

int UiBTTopBar::OnLButtonDown(UINT fwKeys, int xPos, int yPos)
{
	return UiWin::OnLButtonDown(fwKeys, xPos, yPos);

}

int UiBTTopBar::OnLButtonUp(UINT fwKeys, int xPos, int yPos)
{
	return UiWin::OnLButtonUp(fwKeys, xPos, yPos);

}

void UiBTTopBar::LoadiInterItem()
{
//jdhuang 20120818
#ifndef MERGER_APP_TO_SHELL
	m_TopBarBG = ImagingHelper::GetImageObject(MzGetInstanceHandle(), 1063);
#else
	m_TopBarBG = ImagingHelper::GetImageObject(g_SDHResModuleHandle, 5063);
#endif
	
	RECT rtBtnClose = {719, 5, 800, 59};
	m_BtnTopBar[BT_TOPBAR_CLOSE].SetPos(rtBtnClose.left, rtBtnClose.top, rtBtnClose.right-rtBtnClose.left, rtBtnClose.bottom-rtBtnClose.top);
	m_BtnTopBar[BT_TOPBAR_CLOSE].SetID(2000);
#ifndef MERGER_APP_TO_SHELL
	m_BtnTopBar[BT_TOPBAR_CLOSE].SetNormalImage(ImagingHelper::GetImageObject(MzGetInstanceHandle(),1059, true));
	m_BtnTopBar[BT_TOPBAR_CLOSE].SetPressedImage(ImagingHelper::GetImageObject(MzGetInstanceHandle(),1060, true));
#else
	m_BtnTopBar[BT_TOPBAR_CLOSE].SetNormalImage(ImagingHelper::GetImageObject(g_SDHResModuleHandle,5059, true));
	m_BtnTopBar[BT_TOPBAR_CLOSE].SetPressedImage(ImagingHelper::GetImageObject(g_SDHResModuleHandle,5060, true));
#endif
	AddChild(&m_BtnTopBar[BT_TOPBAR_CLOSE]);

	RECT rtBtnMenu = {0, 5, 81, 59};
	m_BtnTopBar[BT_TOPBAR_MENU].SetPos(rtBtnMenu.left, rtBtnMenu.top, rtBtnMenu.right-rtBtnMenu.left, rtBtnMenu.bottom-rtBtnMenu.top);
	m_BtnTopBar[BT_TOPBAR_MENU].SetID(2001);
#ifndef MERGER_APP_TO_SHELL
	m_BtnTopBar[BT_TOPBAR_MENU].SetNormalImage(ImagingHelper::GetImageObject(MzGetInstanceHandle(),1061, true));
	m_BtnTopBar[BT_TOPBAR_MENU].SetPressedImage(ImagingHelper::GetImageObject(MzGetInstanceHandle(),1062, true));
#else
	m_BtnTopBar[BT_TOPBAR_MENU].SetNormalImage(ImagingHelper::GetImageObject(g_SDHResModuleHandle,5061, true));
	m_BtnTopBar[BT_TOPBAR_MENU].SetPressedImage(ImagingHelper::GetImageObject(g_SDHResModuleHandle,5062, true));
#endif
	AddChild(&m_BtnTopBar[BT_TOPBAR_MENU]);

}

BOOL UiBTTopBar::InitImages()
{
/*
	HDC hDC = GetDC(m_hWnd);
//jdhuang

	RECT rcClient = GetClientRect();
//	GetClientRect(m_hWnd, &rcClient);

	m_hBakDC = CreateCompatibleDC(hDC);

	m_hBitmapBakDC = CreateCompatibleBitmap(hDC, RECT_WIDTH(rcClient), RECT_HEIGHT(rcClient));
	SelectObject(m_hBakDC, m_hBitmapBakDC);

	//jdhuang 20090616
//	HDC hMemDc = CreateCompatibleDC(m_hBakDC);

	if(m_TopBarBG)
	{
		m_TopBarBG->Draw(m_hBakDC, &rcClient, false, false);
//		DeleteDC(hMemDc);
	}
	ReleaseDC(m_hWnd, hDC);
*/
	return TRUE;
}
void UiBTTopBar::UpdateLanguage()
{
}
void UiBTTopBar::DeleteImages()
{
	m_TopBarBG->UnloadImage();
}